package com.hl.qzzpbackend.controller;
import com.hl.qzzpbackend.common.BaseResponse;
import com.hl.qzzpbackend.common.ResultUtils;
import com.hl.qzzpbackend.model.dto.companyInfo.CompanyInfoAddRequest;
import com.hl.qzzpbackend.model.dto.resumeInfo.ResumeInfoAddRequest;
import com.hl.qzzpbackend.model.dto.resumeInfo.ResumeInfoUpdateRequest;
import com.hl.qzzpbackend.model.entity.User;
import com.hl.qzzpbackend.model.vo.ResumeInfoVO;
import com.hl.qzzpbackend.service.ResumeInfoService;
import com.hl.qzzpbackend.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;


/**
 * 简历信息接口
 *
 * @author helong
 */
@Slf4j
@Api(tags = "简历信息接口")
@RestController
@RequestMapping("/resume_info")
public class ResumeInfoController {

    @Resource
    private ResumeInfoService resumeInfoService;

    @Resource
    private UserService userService;


    // 添加简历信息
    @ApiOperation(value = "添加简历信息")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public BaseResponse<Boolean> resumeInfoAdd(@Valid @RequestBody ResumeInfoAddRequest resumeInfoAddRequest) {
        if(log.isInfoEnabled()){
            log.info("添加简历信息 {}", resumeInfoAddRequest);
        }
        boolean result = resumeInfoService.resumeInfoAdd(resumeInfoAddRequest);
        return ResultUtils.success(result);
    }

    // 修改简历信息
    @ApiOperation(value = "修改简历信息")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public BaseResponse<Boolean> resumeInfoUpdate(@Valid @RequestBody ResumeInfoUpdateRequest resumeInfoUpdateRequest) {
        if(log.isInfoEnabled()){
            log.info("修改简历信息 {}", resumeInfoUpdateRequest);
        }
        boolean result = resumeInfoService.resumeInfoUpdate(resumeInfoUpdateRequest);
        return ResultUtils.success(result);
    }

    // 获取简历信息
    @ApiOperation(value = "获取简历信息")
    @RequestMapping(value = "/get", method = RequestMethod.POST)
    public BaseResponse<ResumeInfoVO> getResumeInfo(HttpServletRequest request) {
        if(log.isInfoEnabled()){
            log.info("获取简历信息");
        }
        User loginUser = userService.getLoginUser(request);
        ResumeInfoVO resumeInfoVO = resumeInfoService.getResumeInfo(loginUser);
        return ResultUtils.success(resumeInfoVO);
    }







}
